import axios from 'axios';
axios.defaults.withCredentials = true; 
import { Toast } from 'vant';
const baseURL = "http://localhost:4000"
function http({
    url,
    method,
    data
}){
    return new Promise((resolve,reject)=>{
        console.log(baseURL+url);
        axios({
            method,
            url: baseURL+url,
            data,
        }).then((res)=>{
            if(res.status==200){
                resolve(res);
            }else{
                Toast('无法连接网络');
                throw new Error("网络异常");
            }
        }).catch((res)=>{
            reject(res)
            Toast('无法连接网络');
            throw new Error("网络异常");
        })
    })
}
export default http;